<!--
$(document).ready(function()
{
	//表单验证
	$('#btnSignCheck').click(function ()
	{
		var agree = $('#agree').get(0).checked ? 1: 0;
		if(!agree) {
			alert("你必须同意注册协议！");
			return false;
		}
		var user_name = $('#txtUsername').val();
		if(user_name == ""){
			$('#txtUsername').focus();
			alert("用户名不能为空！");
			return false;
		}
		var account_type = $('.usermtype2:eq(0)').attr('checked')=='checked' ? 1 : 2; 
		var unit_name = $('#uname').val();
		if(unit_name == ""){
			$('#uname').focus();
			alert("企业名称或个人昵称不能为空！");
			return false;
		}
		var password = $('#txtPassword').val();
		if(password == "")
		{
			$('#txtPassword').focus();
			alert("登陆密码不能为空！");
			return false;
		}
		var passconf = $('#userpwdok').val();
		if(passconf!=password)
		{
			$('#userpwdok').focus();
			alert("密码和确认密码不一致！");
			return false;
		}
		var question_id = $('#safequestion :selected').val();
		var answer = $('#safeanswer').val();
		if(question_id!="0" && answer=="")
		{
			$('#safeanswer').focus();
			alert("问题答案不能为空！");
			return false;
		}
		var vdcode = $('#vdcode').val();
		if(vdcode == "")
		{
			$('#vdcode').focus();
			alert("验证码不能为空！");
			return false;
		}
		if(vdcode.length != 4)
		{
			$('#vdcode').focus();
			alert("验证码长度必须为四位！");
			return false;
		}
		//ajax提交数据
		var url = window.location.href;
		var query = {user_name : user_name, unit_name : unit_name, password : password, passconf : passconf, email : $("#email").val(), account_type : account_type, question_id : question_id}; 
		query.register  = 1; query.agree = agree; query.vdcode = vdcode;
		query.answer = question_id!='0' ? answer : '';
		$.post(url, query, function(data){
			if(data.indexOf('/') != '-1'){
				location.href = data;
			}else{
				alert(data);
				changeCode('vdcode');
			}
		}, 'html');
	})
	
	//ajax验证用户名是否唯一
	$("#txtUsername").change( function() {
		if(($(this).val()).indexOf('@')!='-1' || ($(this).val()).indexOf('.')!='-1'){
			$('#_userid').html("<font color='red'><b>×用户名格式不正确</b></font>");
		}else{
			var url = 'ajaxRegCheck';
			var query = {flag : 'checkUser', user_name : $(this).val()};
			$.post(url, query, function(data){
				if(data != 'ok'){
					$('#_userid').html(data);
				}else{
					$('#_userid').html('(可以使用中文，但禁止除[@][.]以外的特殊符号)');
				}
			}, 'html');
		}
	});
	
	//ajax验证邮箱是否唯一
	$("#email").change( function() {
		var sEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		if(!sEmail.exec($("#email").val()))
		{
			$('#_email').html("<font color='red'><b>×Email格式不正确</b></font>");
			$('#email').focus();
		}else{
			var url = 'ajaxRegCheck';
			var query = {flag : 'checkEmail', email : $(this).val()};
			$.post(url, query, function(data){
				if(data != 'ok'){
					$('#_email').html(data);
				}else{
					$('#_email').html('(每个电子邮邮箱只能注册一个帐号)');
				}
			}, 'html');
		}
	});	
	
	var pwdmin = 6;
	//密码验证
	$('#txtPassword').change( function(){
		if($('#txtPassword').val().length < pwdmin)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+pwdmin+"位</b></font>");
		}
		else if($('#userpwdok').val()!=$('txtPassword').val())
		{
			$('#_userpwdok').html("<font color='red'><b>×两次输入密码不一致</b></font>");
		}
		else if($('#userpwdok').val().length < pwdmin)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+pwdmin+"位</b></font>");
		}
		else
		{
			$('#_userpwdok').html("<font color='#4E7504'><b>√填写正确</b></font>");
		}
	});
	
	//确认密码验证
	$('#userpwdok').change( function(){
		if($('#txtPassword').val().length < pwdmin)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+pwdmin+"位</b></font>");
		}
		else if($('#userpwdok').val()=='')
		{
			$('#_userpwdok').html("<b>请填写确认密码</b>");
		}
		else if($('#userpwdok').val()!=$('#txtPassword').val())
		{
			$('#_userpwdok').html("<font color='red'><b>×两次输入密码不一致</b></font>");
		}
		else
		{
			$('#_userpwdok').html("<font color='#4E7504'><b>√填写正确</b></font>");
		}
	});
});
-->